package com.fc.test.service;

import java.util.List;
import java.util.Arrays;

import com.fc.test.model.auto.EntCollect;
import com.fc.test.model.auto.EntCollectExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.hutool.core.util.StrUtil;
import com.fc.test.common.base.BaseService;
import com.fc.test.common.support.ConvertUtil;
import com.fc.test.mapper.auto.JobRecMapper;
import com.fc.test.model.auto.JobRec;
import com.fc.test.model.auto.JobRecExample;
import com.fc.test.model.custom.Tablepar;
import com.fc.test.util.SnowflakeIdWorker;
import com.fc.test.util.StringUtils;

/**
 * 职位推荐信息 JobRecService
 * @Title: JobRecService.java 
 * @Package com.fc.test.service 
 * @author DrRic_自动生成
 * @email drhyz@qq.com
 * @date 2020-07-05 17:21:20  
 **/
@Service
public class JobRecService implements BaseService<JobRec, JobRecExample>{
	@Autowired
	private JobRecMapper jobRecMapper;
	
      	   	      	      	      	      	
	/**
	 * 分页查询
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	 public PageInfo<JobRec> list(Tablepar tablepar,JobRec record){
	        JobRecExample testExample=new JobRecExample();
	        testExample.createCriteria().andLikeQuery(record);
	        testExample.setOrderByClause("id ASC");
			if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
	        	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
	        }
	        PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
	        List<JobRec> list= jobRecMapper.selectByExample(testExample);
	        PageInfo<JobRec> pageInfo = new PageInfo<JobRec>(list);
	        return  pageInfo;
	 }

	public PageInfo<JobRec> listForSys(Tablepar tablepar, JobRec record){
		JobRecExample testExample=new JobRecExample();
		testExample.createCriteria().andLikeQuery(record);
		testExample.setOrderByClause("id ASC");
		if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
			testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
		}
		PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
		List<JobRec> list= jobRecMapper.selectByExample(testExample);
		PageInfo<JobRec> pageInfo = new PageInfo<JobRec>(list);
		return  pageInfo;
	}

	@Override
	public int deleteByPrimaryKey(String ids) {
					
			Integer[] integers = ConvertUtil.toIntArray(",", ids);
			List<Integer> stringB = Arrays.asList(integers);
			JobRecExample example=new JobRecExample();
			example.createCriteria().andIdIn(stringB);
			return jobRecMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public JobRec selectByPrimaryKey(String id) {
				
			Integer id1 = Integer.valueOf(id);
			return jobRecMapper.selectByPrimaryKey(id1);
				
	}

	
	@Override
	public int updateByPrimaryKeySelective(JobRec record) {
		return jobRecMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(JobRec record) {
				
		record.setId(null);
		
				
		return jobRecMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(JobRec record, JobRecExample example) {
		
		return jobRecMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(JobRec record, JobRecExample example) {
		
		return jobRecMapper.updateByExample(record, example);
	}

	@Override
	public List<JobRec> selectByExample(JobRecExample example) {
		
		return jobRecMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(JobRecExample example) {
		
		return jobRecMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(JobRecExample example) {
		
		return jobRecMapper.deleteByExample(example);
	}
	
	/**
	 * 检查name
	 * @param jobRec
	 * @return
	 */
	public int checkNameUnique(JobRec jobRec){
		JobRecExample example=new JobRecExample();
		example.createCriteria().andRecStatusEqualTo(jobRec.getRecStatus());
		List<JobRec> list=jobRecMapper.selectByExample(example);
		return list.size();
	}


}
